package com.dranie.validator;

import com.dranie.entity.User;
import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;

/**
 * BlogValidator.
 */
public class UserValidator extends Validator {

	protected void validate(Controller controller) {
		validateRequiredString("validator.title", "titleMsg", "请输入User标题!");
		validateRequiredString("validator.content", "contentMsg", "请输入User内容!");
	}

	protected void handleError(Controller controller) {
		controller.keepModel(User.class);

		String actionKey = getActionKey();
		if (actionKey.equals("/admin/user/save"))
			controller.render("add.html");
		else if (actionKey.equals("/admin/user/update"))
			controller.render("edit.html");
	}
}
